/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.moviedownloader.DbModel;

import java.util.Objects;

/**
 *
 * @author martin
 */
public class Title{

    private String country;
    private String title;
    private Long id;

    public Title(String country, String title) {
        this.country = country;
        this.title = title;
    }

    private Title() {
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getName() {
        return title;
    }

    public void setName(String name) {
        this.title = name;
    }

    @Override
    public String toString() {
        return "MovieName{" + "country=" + country + ", title=" + title + '}';
    }

    public String getCandidateKey() {
        return this.title;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String toCsv() {
        return country + "#" + title + "#" + id;
    }

    public Title fromString(String line) {
        Objects.requireNonNull(line);
        String[] split = line.split("#");
        Title name = new Title();
        name.country = split[0];
        name.title = split[1];
        name.id = Long.parseLong(split[2]);
        return name;
    }
}
